import request from '@/utils/request';
import {FunctionInterfaceDTO, InterfaceDTO, InterfaceQueryDTO} from "@/types/interface";
import {stringify} from "querystring";

export async function createFunctionInterfaceRelation(params:FunctionInterfaceDTO): Promise<any> {
  return request('/function_interface/create',{
    method: 'POST',
    data: params,
  });
}

export async function deleteFunctionInterfaceRelation(params:{interfaceId:string | number,functionId:string|number}): Promise<any> {
  return request(`/function_interface/delete?${stringify(params)}`,{
    method: 'DELETE',
  });
}

export async function queryUnassignedList(params:InterfaceQueryDTO): Promise<any> {
  return request('/interface/query_unassigned_list',{
    method: 'POST',
    data: params,
  });
}

export async function queryAssignedList(params:InterfaceQueryDTO): Promise<any> {
  return request('/interface/query_assigned_list',{
    method: 'POST',
    data: params,
  });
}

export async function queryList(params:InterfaceQueryDTO): Promise<any> {
  return request('/interface/query_list',{
    method: 'POST',
    data: params,
  });
}

export async function create(params:InterfaceDTO): Promise<any> {
  return request('/interface/create',{
    method: 'POST',
    data: params,
  });
}

export async function modify(params:InterfaceDTO): Promise<any> {
  return request('/interface/modify',{
    method: 'PUT',
    data: params,
  });
}

export async function _delete(params:{id:string | number}): Promise<any> {
  return request(`/interface/delete?${stringify(params)}`,{
    method: 'DELETE',
  });
}

export default {
  createFunctionInterfaceRelation,
  deleteFunctionInterfaceRelation,
  queryUnassignedList,
  queryAssignedList,
  queryList,
  create,
  modify,
  _delete,
}
